/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.socialNet.command;

import com.bionic.socialNet.commandBeans.UserBean;
import com.bionic.socialNet.entities.ProfileData;
import static com.bionic.socialNet.manager.AttributeNames.*;
import com.bionic.socialNet.manager.Config;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Ann Redirect to user's common profile (global profile everyone sees)
 */
public class CommandCommonProfile implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //
        String page = Config.getInstance().getProperty(Config.COMMON_PROFILE);
        int commonUserID = Integer.parseInt(request.getParameter(COMMON_USER_ID));
        UserBean userBean = new UserBean();
        ProfileData commonProfile = new ProfileData();
        commonProfile = userBean.findCommonProfile(commonUserID);
        request.setAttribute(FULL_NAME, commonProfile.getFullname());
        request.setAttribute(NICKNAME, commonProfile.getNickname());
        request.setAttribute(BIRHDAY, commonProfile.getBirthday());
        request.setAttribute(ABOUT, commonProfile.getAbout());
        request.setAttribute(USER_ID, commonProfile.getUserId());
        return page;
    }
}
